package com.cskaoyan.day5.deque._03_constructor;

import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

/**
 * @author Common-zhou
 * @since 2023-03-03 14:48
 */
public class BlockingQueueDemo1 {
    public static void main(String[] args) throws InterruptedException {

        BlockingQueue<String> blockingQueue = new LinkedBlockingQueue<>(4);

        blockingQueue.put("zs");
        blockingQueue.put("ls");
        blockingQueue.put("wu");
        blockingQueue.put("zl");
        // 当插入的时候，超过了容量的限制，会卡在这里
        //blockingQueue.put("put");

        // 添加的时候，如果队列满了，使用add方法来添加，这时候会有异常
        //blockingQueue.add("zs");

        // offer方法，会返回false
        //boolean offer = blockingQueue.offer("zs");
        //System.out.println(offer);

        // zs   ls    wu
        System.out.println(blockingQueue);



    }
}
